<?php

class Controller_Admin_Appearance_Template_Edit extends Controller
{
	function execute($request)
	{
		$_id = intval($request -> getParam('_id'));
		$item = Model::factory('agilet_template', $_id);
		$form = new Form_Admin_Template_AddElement;

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$values = $form -> getValues();

			$item -> editElement($values);

			$item -> save();
		}
		$request -> response = View::render(array(
			'form' => $form,
			'item' => $item
		), 'admin/edit');
	}

}
